package com.zxd.controller.backend;

import com.zxd.service.RoleModuleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

/**
 * 总管理后台控制面板
 * Created by 涂奕恒 on 2019/01/28.
 */
@Controller
@RequestMapping(value = "backend")
public class BackendIndexController {

    @Autowired
    private RoleModuleService roleModuleService;

    @RequestMapping(value = "/dashboard")
    public String dashboard() {
        return "backend/home";
    }

    @RequestMapping(value = "/index")
    public String index(Model model) {
        model.addAttribute("groupId", 0);
        model.addAttribute("level", 1);
        return "backend/welcome";
    }

    @RequestMapping(value = "/getMenuList")
    @ResponseBody
    public List<Map<String, Object>> getMenuList(HttpServletRequest request, Integer parentId) {
        return roleModuleService.getMenuByParams(request, parentId);
    }
}
